package com.lineage.server.model.skill.skillmode;

import com.lineage.config.ConfigElfSkill;
import com.lineage.server.datatables.SprTable;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1Character;
import com.lineage.server.model.L1Magic;
import com.lineage.server.serverpackets.S_SkillSound;
import com.lineage.server.serverpackets.ServerBasePacket;

public class TRIPLE_ARROW extends SkillMode {
  public int start(L1PcInstance srcpc, L1Character cha, L1Magic magic, int integer) throws Exception {
    int dmg = 0;
    int playerGFX = srcpc.getTempCharGfx();
    int attack21 = SprTable.get().getAttackSpeed(playerGFX, 21);
    if (attack21 == 0)
      return 0; 
    if (ConfigElfSkill.TRIPLE_ARROW_DMG > 1.0D)
      srcpc.setIsTRIPLE_ARROW(true); 
    srcpc.setTripleArrow(true);
    int i = 0;
    while (i < 3) {
      cha.onAction(srcpc);
      i++;
    } 
    if (ConfigElfSkill.TRIPLE_ARROW_DMG > 1.0D)
      srcpc.setIsTRIPLE_ARROW(false); 
    srcpc.sendPacketsAll((ServerBasePacket)new S_SkillSound(srcpc.getId(), 11764));
    return 0;
  }
  
  public int start(L1NpcInstance npc, L1Character cha, L1Magic magic, int integer) throws Exception {
    int dmg = 0;
    cha.setTripleArrow(true);
    int i = 3;
    while (i > 0) {
      npc.attackTarget(cha);
      i--;
    } 
    npc.broadcastPacketAll((ServerBasePacket)new S_SkillSound(npc.getId(), 11764));
    return 0;
  }
  
  public void start(L1PcInstance srcpc, Object obj) throws Exception {}
  
  public void stop(L1Character cha) throws Exception {}
}
